<?php


namespace core\traits;


trait SingletonTrait
{
    private static $instance;

    /**
     * @return static
     */
    public static function getInstance()
    {
        if (null === static::$instance) {
            static::$instance = new static();
        }

        return static::$instance;
    }

    private function __construct()
    {
        // 初始化代码
    }

    private function __clone()
    {
    }

}